UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'xZkFuVIw4IjfB0Qk6suv+C+Cf/lYXk5fumgn1x4++E8='
WHERE
key_id = 'a05f9d52092276345c640f07ab934ae2d3adb013e530834ca286c164a2088edb'
AND (
token = 'xZkFuVIw4IjfB0Qk6suv+C+Cf/lYXk5fumgn1x4++E8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)