UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '3Hm+oP7/631JCACVHnypjGtA7Sx+gCwuA9SNuAPQP3Y=' 
WHERE 
  key_id = 'aa2ca3dca02ce1121d31e5507300c35c286c48edab57c012f53a38ada1c94bd9' 
  AND (
    token = '3Hm+oP7/631JCACVHnypjGtA7Sx+gCwuA9SNuAPQP3Y=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026